import json
from pyecharts.globals import ThemeType
from pyecharts.charts import Timeline

my_list=[["a",23],["b",3],["c",34]]
print("函数是：",my_list)
my_list.sort(key=lambda e:e[1],reverse=True)
print("对列表进行排序，用列表中元素列表的第二个元素来进行排序，排序后的列表是：",my_list)
with open("1960-2019全球GDP数据.csv","r",encoding="GB2312") as f:
    lines=f.readlines()
lines.pop(0)
data_dict={}
print(lines)
print(str(lines[0]),type(str(lines[0])))
for line in lines:
    year=int(line.split(",")[0])
    country=line.split(",")[1]
    gdp=line.split(",")[2]
    try:
        data_dict[year].append((country,gdp))
    except KeyError as e:
        data_dict[year]=[]
        data_dict[year].append((country, gdp))
sorted_year_list=sorted(data_dict.keys())
print(data_dict)